package com.ithuang.demo.service;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;

@Service
public class FileService {


    @Async
    public void FileAnalysis(MultipartFile file) throws Exception {
        //睡眠1s 模拟业务操作
        Thread.sleep(1000);
        file.transferTo(new File("D:\\"+file.getOriginalFilename()));
    }

//    @Async
    public void FileAnalysis2(InputStream inputStream) throws Exception {
        //睡眠1s 模拟业务操作
        Thread.sleep(1000);
        Workbook workbook = new XSSFWorkbook(inputStream);
        inputStream.close();
    }
}
